﻿using MessagePack;
using StudentAgeSaveEditor.GameData.Effect;
using StudentAgeSaveEditor.GameData.TheEntity;
using StudentAgeSaveEditor.GameData.Wapper;

namespace StudentAgeSaveEditor.GameData
{
    class Role : Entity
    {
        public string saveUid;

        private Dictionary<int, float> attrDict;

        public List<int> changeAttrs;

        private Dictionary<int, PersonalityData> personalityEnhanceDatas;
        public bool enableFavorDownEachYear = true;

        public bool isLeave;

        public int traitChangeCnt;

        public int socialEvtId;

        public int taskEvtId;

        public Dictionary<int, Effector> relationEffector;

        public ulong traitHelperUid;

        public List<ulong> relationUids;

        private List<ulong> loveUids;

        public Dictionary<int, ulong> relationIncDictOfEffect;

        private List<ulong> traitUids;

        public int vindicateCnt;

        public (int year, int month) lastVindicateTime;

        public int loverId;

        public bool ignoreEarlyLoveEffect;

        public ulong focusStateUid;

        public int focusStateId;

        public int id { get; private set; }

        public bool IsMainRole { get; private set; }

        [IgnoreMember]
        public float Age
        {
            get
            {
                int year = Singleton<RoundMgr>.Ins.GetYear();
                int month = Singleton<RoundMgr>.Ins.GetMonth();
                int num = Birthday[0];
                int num2 = Birthday[1];
                float num3;
                if (num2 > month)
                {
                    num3 = (float)(12 - num2 + 1 + month) / 12f;
                    num++;
                }
                else
                {
                    num3 = (float)(month - num2 + 1) / 12f;
                }

                return (float)(year - num) + num3;
            }
        }

        public List<int> Birthday { get; private set; }
        public GenderDefine Sex { get; private set; }

        public string NameXing { get; private set; }

        public string NameMing { get; private set; }

        public string Name { get; private set; }

        public string Gender
        {
            get
            {
                if (Sex == GenderDefine.Male)
                {
                    return "男";
                }

                if (Sex == GenderDefine.Female)
                {
                    return "女";
                }

                return "未知";
            }
        }

        public (int rank, float src, float target) IQRank { get; private set; }

        public (int rank, float src, float target) EQRank { get; private set; }

        public (int rank, float src, float target) HealthRank { get; private set; }

        public List<int> MainPersonalitys { get; private set; }

        public PersonalityTypeData PersonalityTypeData { get; private set; }

        public int PrimaryPersonalityId { get; private set; } = -1;


        public int Grade { get; private set; }

        public int Education { get; private set; }

        public float Favor { get; private set; }

        public Dictionary<int, NpcItem> Items { get; private set; }

        public int Trait { get; private set; }

        public List<int> Traits { get; private set; }

        public int Relation { get; set; }

        public List<int> MeetDate { get; private set; }

        public RoleIncreaserCtrl IncCtrl { get; private set; }

        public bool IsLover { get; private set; }

        public int FocusId { get; private set; }

        public int LoveLevel { get; private set; }

        public List<int> LoveDate { get; private set; }

        public List<CharacterData> Characters { get; private set; }

        public Dictionary<int, CharacterTendencyData> CharacterTendencys { get; private set; }
        public List<StateData> States { get; private set; }
        public Role()
        {
            attrDict = new Dictionary<int, float>();
            Characters = new List<CharacterData>();
            States = new List<StateData>();
            IncCtrl = new RoleIncreaserCtrl();
            CharacterTendencys = new Dictionary<int, CharacterTendencyData>();
            MainPersonalitys = new List<int>();
            relationEffector = new Dictionary<int, Effector>();
            personalityEnhanceDatas = new Dictionary<int, PersonalityData>();
            PersonalityTypeData = new PersonalityTypeData();
        }

    }
}
